﻿package mortal.game.view.common
{
    import mortal.common.cd.*;
    import mortal.game.view.common.display.*;

    public class SecTimerBitmapView extends BitmapNumberText
    {
        protected var _secTimerViewData:SecTimerViewData;
        protected var _strParse:String = "mm:ss";
        protected var _timeOutCallBack:Function;
        protected var _caller:Function;

        public function SecTimerBitmapView()
        {
            return;
        }// end function

        public function setLeftTime(param1:int, param2:Boolean = true) : void
        {
            if (param1 < 0)
            {
                param1 = 0;
            }
            if (!this._secTimerViewData)
            {
                this._secTimerViewData = new SecTimerViewData();
            }
            this._secTimerViewData.setLeftTime(param1, param2);
            this._secTimerViewData.caller = this.update;
            if (this._timeOutCallBack != null)
            {
                this._secTimerViewData.timeOutCaller = this._timeOutCallBack;
            }
            this.update();
            return;
        }// end function

        public function getLeftTime() : int
        {
            if (this._secTimerViewData)
            {
                return this._secTimerViewData.leftTime;
            }
            return 0;
        }// end function

        public function stop() : void
        {
            if (this._secTimerViewData)
            {
                this._secTimerViewData.stop();
            }
            return;
        }// end function

        protected function update() : void
        {
            this.text = this._secTimerViewData.parse(this._strParse);
            if (this._caller != null)
            {
                this._caller.apply();
            }
            return;
        }// end function

        public function set caller(param1:Function) : void
        {
            this._caller = param1;
            return;
        }// end function

        public function setParse(param1:String) : void
        {
            this._strParse = param1;
            return;
        }// end function

        override public function dispose(param1:Boolean = true) : void
        {
            if (this._secTimerViewData)
            {
                this._secTimerViewData.dispose();
            }
            this._secTimerViewData = null;
            this._timeOutCallBack = null;
            this._caller = null;
            super.dispose(param1);
            return;
        }// end function

        public function changeCheckLabel(param1:String, param2:String) : void
        {
            if (!this._secTimerViewData)
            {
                this._secTimerViewData = new SecTimerViewData();
            }
            this._secTimerViewData.changeCheckLabel(param1, param2);
            return;
        }// end function

        public function get secTimerViewData() : SecTimerViewData
        {
            return this._secTimerViewData;
        }// end function

        public function set timeOutHandler(param1:Function) : void
        {
            this._timeOutCallBack = param1;
            if (this._secTimerViewData)
            {
                this._secTimerViewData.timeOutCaller = this._timeOutCallBack;
            }
            return;
        }// end function

        public function get running() : Boolean
        {
            if (this._secTimerViewData)
            {
                return this._secTimerViewData.running;
            }
            return false;
        }// end function

        public function get parse() : String
        {
            return this._strParse;
        }// end function

    }
}
